/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.utils;

/**
 * Created by Peter.Li on 2015/10/23.
 */
public enum Model {
    NORMAL(1, "NORMAL"),
    SLOT(2, "SLOT");

    private int index;
    private String code;

    Model(int index, String code) {
        this.code = code;
        this.index = index;
    }

    public static Model getValueOf(String code) {
        if (NORMAL.getCode().equals(code)) {
            return NORMAL;
        } else if (SLOT.getCode().equals(code)) {
            return SLOT;
        } else {
            return null;
        }
    }

    public static Model getValueOf(int index) {
        switch (index) {
            case 1:
                return NORMAL;
            case 2:
                return SLOT;
            default:
                return null;
        }
    }

    public String getCode() {
        return code;
    }

    public int getIndex() {
        return index;
    }
}
